package com.baizhi.service.impl;

import com.baizhi.entity.PmsAttrGroup;
import com.baizhi.dao.PmsAttrGroupMapper;
import com.baizhi.entity.PmsCategory;
import com.baizhi.service.IPmsAttrGroupService;
import com.baizhi.service.IPmsCategoryService;
import com.baizhi.vo.PmsAttrGroupVo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 属性分组 服务实现类
 * </p>
 *
 * @author xhc
 * @since 2020-09-29
 */
@Service
public class PmsAttrGroupServiceImpl extends ServiceImpl<PmsAttrGroupMapper, PmsAttrGroup> implements IPmsAttrGroupService {

    @Autowired
    private IPmsCategoryService  categoryService;


    @Transactional
    @Override
    public void savePmsAttrGroup(PmsAttrGroupVo pmsAttrGroupVo) {
        PmsAttrGroup pmsAttrGroup = new PmsAttrGroup();
        PmsCategory pmsCategory = categoryService.selectCategoryByName(pmsAttrGroupVo.getCategoryName());
        BeanUtils.copyProperties(pmsAttrGroupVo,pmsAttrGroup);
        pmsAttrGroup.setCategoryId(pmsCategory.getCatId());
        save(pmsAttrGroup);
    }
}
